<template>
  <div>
       <el-table
    :data="comments"
    style="width: 100%">

        <el-table-column
        label="评论ID"
        width="180"
        prop="userInfoBean.userName">
        </el-table-column>
        <el-table-column
        label="评论内容"
        width="180"
        prop="commentContent">
        </el-table-column>
        <el-table-column
        label="点赞数"
        width="180"
        prop="commentLikeCount">
        </el-table-column>
        <el-table-column
                label="点赞"
                width="220">
                    <template slot-scope="scope">
                        <span v-if="checkLike(scope.row)"><img :src=add @click="addLiked(scope.row)"></span>
                        <span v-else><img :src=cancel @click="cancelLikes(scope.row)"></span>
                    <el-badge :value="scope.row.count" class="item"></el-badge>
                </template>
                </el-table-column>

  </el-table>
  </div>
</template>

<script>
import {mapState,mapActions} from 'vuex'
export default {
    created(){
       this.setComments();
    },
    computed:{
        ...mapState("user",["comments"]),
    },
    methods:{
        ...mapActions("user",["setComments"]),
         async addLikes(row){
            var response = await this.ajax.postSubmit("/project/users/addLiked",{userId:row.user.userId,commentId:row.comId});
            if(response.status == 1){
                this.checkLike(row)
               
            }
         }
    }

}
</script>

<style>

</style>